package com.moleq.dialog;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.moleq.base.MoleQBaseDialog;
import com.moleq.logic.MoleQConstants;
import com.moleq.mgpos.activities.R;
import com.moleq.util.ImageUtil;

public class ConfirmSignatureDialog extends MoleQBaseDialog {

	private Button mBtnConfirm, mBtnResign;
	private String mSign = "";
	private ImageView imageView;

	private Button.OnClickListener mOnClickListener = new Button.OnClickListener() {

		@Override
		public void onClick(View v) {
			switch (v.getId()) {
			case R.id.btnConfirmSignature:
				onReturnValue(MoleQConstants.ON_CLICK_CONFIRM_SIGNATURE, mSign);
				dismiss();
				break;
			case R.id.btnReSignature:
				onReturnValue(MoleQConstants.ON_CLICK_REGET_SIGNATURE, "");
				dismiss();
				break;
			}
		}
	};

	public ConfirmSignatureDialog(Context context) {
		super(context, R.style.dialog, context);
		constructor(context);
	}

	public ConfirmSignatureDialog(Context context, Object listener) {
		super(context, listener);
		constructor(context);
	}

	private void constructor(Context context) {
		// TODO Auto-generated method stub
		mContext = context;
	}

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		// set UI layout
		this.setContentView(R.layout.dialog_perview_signature);
		this.setCancelable(false);

		mBtnConfirm = (Button) findViewById(R.id.btnConfirmSignature);
		mBtnConfirm.setOnClickListener(mOnClickListener);

		mBtnResign = (Button) findViewById(R.id.btnReSignature);
		mBtnResign.setOnClickListener(mOnClickListener);

		imageView = (ImageView) findViewById(R.id.iv_preview);

	}

	public void show(String bitMapString) {
		super.show();
		mSign = bitMapString;
		imageView.setImageBitmap(ImageUtil.stringtoBitmap(mSign));
		//
	}

}
